using System;
using System.Net.NetworkInformation;

// 抽象产品 - 计算机
public interface IComputer
{
    void Launch();
}

// 抽象产品 - 手机
public interface IPhone
{
    void Launch();
}

// 具体产品 - MacBook
public class MacBook : IComputer
{
    public void Launch()
    {
        Console.WriteLine("MacBook launched.");
    }
}

// 具体产品 - MiBook
public class MiBook : IComputer
{
    public void Launch()
    {
        Console.WriteLine("MiBook launched.");
    }
}

// 具体产品 - iPhone
public class iPhone : IPhone
{
    public void Launch()
    {
        Console.WriteLine("iPhone launched.");
    }
}

// 具体产品 - MiPhone
public class MiPhone : IPhone
{
    public void Launch()
    {
        Console.WriteLine("MiPhone launched.");
    }
}

// 抽象工厂
public interface IAbstractFactory
{
    IComputer CreateComputer();
    IPhone CreatePhone();
}

// 具体工厂 - AppleFactory
public class AppleFactory : IAbstractFactory
{
    public IComputer CreateComputer()
    {
        return new MacBook();
    }

    public IPhone CreatePhone()
    {
        return new iPhone();
    }
}

// 具体工厂 - MiFactory
public class MiFactory : IAbstractFactory
{
    public IComputer CreateComputer()
    {
        return new MiBook();
    }

    public IPhone CreatePhone()
    {
        return new MiPhone();
    }
}

// 客户端代码
public class Client
{
    public void ClientCode(IAbstractFactory factory)
    {
        IComputer computer = factory.CreateComputer();
        IPhone phone = factory.CreatePhone();

        computer.Launch();
        phone.Launch();
    }
}

// 程序入口
class Program
{
    static void Main(string[] args)
    {
        Client client = new Client();

        // 使用AppleFactory
        IAbstractFactory appleFactory = new AppleFactory();
        client.ClientCode(appleFactory);

        // 使用MiFactory
        IAbstractFactory miFactory = new MiFactory();
        client.ClientCode(miFactory);
    }
}

//输出结果
//MacBook launched.
//iPhone launched.
//MiBook launched.
//MiPhone launched.